{extend name="$base" /}
{block name="resources"}{/block}
{block name="main"}
<div class="options-btn">
	<button class="btn-common btn-small" onclick="location.href='{:__URL('ADMIN_MAIN/member/editmemberlabel')}';">添加标签</button>
</div>
<table class="table-class">
	<colgroup>
		<col style="width: 2%">
		<col style="width: 29%;">
		<col style="width: 29%;">
		<col style="width: 30%;">
		<col style="width: 10%;">
	</colgroup>
	<thead>
		<tr align="center">
			<th ><i class="checkbox-common"><input type="checkbox" ></i></th>
			<th align="left">标签名称</th>
			<th align="left">标签描述</th>
			<th align="left">创建时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{/block}
{block name="script"}
<script type="text/javascript">
function LoadingInfo(page_index) {
	$.ajax({
		type : "post",
		url : __URL("ADMIN_MAIN/member/memberlabellist"),
		data : { "page_index" : page_index, "page_size" :  $("#showNumber").val() },
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ data["data"][i]["id"]+'" ></i></td>';
					html += '<td align="left">'+ data["data"][i]["label_name"]+'</td>';
					html += '<td align="left">'+ data["data"][i]["desc"]+'</td>';
					html += '<td align="left">'+ timeStampTurnTime(data["data"][i]["create_time"])+'</td>';
					html += '<td><a href="'+__URL('ADMIN_MAIN/member/editmemberlabel?id='+ data['data'][i]['id'])+'">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:deleteMemberLabel('+data['data'][i]['id']+');">删除</a></td>';
					html += '</tr>';
					$(".table-class tbody").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="4">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

function deleteMemberLabel(id){
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {
				$.ajax({
					type : "post",
					url : "{:__URL('ADMIN_MAIN/member/deletememberlabel')}",
					data : { 'id' : id },
					success : function(data) {
						if (data['code'] > 0) {
							LoadingInfo(getCurrentIndex(id.toString(),'.table-class tbody'));
							showTip(data["message"],'success');
							$("#chek_all").prop("checked", false);
						} else {
							showTip(data['message'],'error');
						}
					}
				});
				$(this).dialog('close');
			},
			"取消,#f5f5f5,#666": function() {
				$(this).dialog('close');
			},
		},
		contentText:"确定要删除吗？",
	});
}
</script>
{/block}